﻿package com.oneko.publicidad {
	
	public class PubliParser {
		
		// Constants:
		// Public Properties:
		// Private Properties:
	
		// Initialization:
		public function PubliParser() { }
	
		public static function parse(dat:XML):Array {
			if (dat.localName()=='VideoAdServingTemplate'){
				return parseVideoAdServingTemplate(dat);
			}
			var arr:Array = new Array();
				
			for each (var i:XML in dat.children()) {
				trace("NOMBRE NODO->"+i.localName());
				trace("VALOR NODO=>"+i);
				arr[i.localName()]=i;
			}
			return arr;
		};
		
		/** . **/
		public static function parseMult(dat:XML):Array {
			var arr:Array = new Array();
			
			var x:Number=0;
			for each (var i:XML in dat.children()) {
				arr[x]=new Array();
				trace("NOMBRE NODO->"+i.localName());
				trace("VALOR NODO=>"+i);
				for each (var j:XML in i.children()) {
					arr[x][j.localName()]=j;
				}
				x++;
			}
			return arr;
		};
		
		public static function parseVideoAdServingTemplate(dat:XML):Array{
			var arr:Array = new Array();
			arr['urlvideo']=dat.Ad.InLine.Video.MediaFiles.MediaFile.URL;
			arr['urlclick']=dat.Ad.InLine.Video.VideoClicks.ClickThrough.URL;
			arr['urlpixel']=dat.Ad.InLine.Impression.URL
			arr['tiempovideo']=dat.Ad.InLine.Video.Duration;
			return arr;
		}
	}
	
}